"use strict";
cc._RF.push(module, '160cefok81B3bumR+1BFrlj', 'HandBook');
// scripts/HandBook.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("GlobalUserData"),
    s = t("BoxGetItem"),
    l = t("ConfirmRewardPanel"),
    c = t("HallConstant"),
    d = t("HallScene"),
    h = t("BroadCastMessage"),
    p = t("Util"),
    u = t("Particle"),
    f = t("BaseStorage"),
    m = cc._decorator,
    _ = m.ccclass,
    y = m.property,
    g = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.pfb_Item = null, e.frame_Arr = new Array(), e.label_title = null, e.node_Btn = null, e.node_togetIocn = null, e.node_rewardIocn = null, e.prefab = null, e.frame_icon = null, e.frame_get = null, e.frame_recive = null, e.qualityText_arr = ["普通", "史诗", "传说"], e.itemScript = null, e.comData = null, e._key = null, e;
  }

  return n(e, t), e.prototype.onLoad = function () {
    var t = cc.instantiate(this.pfb_Item);
    this.node.getChildByName("frame").addChild(t), t.y += 5, this.itemScript = t.getComponent(s["default"]);
  }, e.prototype.start = function () {
    cc.resources.load("prefab/confirmRewardPanel");
  }, e.prototype.updata = function (t) {
    this.itemScript.updateView(t, !0, this.setBtnStatus.bind(this)), this.comData = {
      type: t.type,
      id: t.id,
      quality: t.quality,
      star: t.star
    }, this.setBtnStatus(this.comData), this.node.getChildByName("frame").getComponent(cc.Sprite).spriteFrame = this.frame_Arr[t.quality], this.label_title.string = t.name + "(" + this.qualityText_arr[t.quality] + ")";
  }, e.prototype.setBtnStatus = function (t) {
    this.comData = t, this._key = t.id + t.quality + t.star, this.node_Btn.active = !f.BaseStorage.getInt(this._key, 0), this.node_togetIocn.active = !p.Util.comparison(t), this.node_rewardIocn.active = p.Util.comparison(t), p.Util.comparison(t) ? this.node_Btn.getComponent(cc.Sprite).spriteFrame = this.frame_recive : this.node_Btn.getComponent(cc.Sprite).spriteFrame = this.frame_get;
  }, e.prototype.onBtnClick = function () {
    var t = this;
    if (this.node_togetIocn.active) cc.find("Canvas").getComponent(d["default"]).onBtnShop(!1);else if (this.node_rewardIocn.active) {
      var e = cc.instantiate(cc.resources.get("prefab/confirmRewardPanel"));
      cc.find("Canvas").addChild(e, 100), e.getComponent(l["default"]).initView([{
        type: l.rewardType.diamond,
        num: 10 * this.comData.star
      }], function () {
        r["default"].saveDiamondData(!0, 10 * t.comData.star), cc.find("Canvas").getComponent(d["default"]).onSetOwnDiamond(!0), t.action(), f.BaseStorage.setInt(t._key, 1), t.setBtnStatus(t.comData);
      });
    }
  }, e.prototype.setStarNum = function (t) {
    this.itemScript.showStar(t);
  }, e.prototype.action = function () {
    h["default"].getInstance().SendMessage(c.Broadcast_Func.Audio, c.Audio_ID.get_gold);

    for (var t = 0; t < 20; t++) {
      var e = cc.instantiate(this.prefab),
          o = this.node_Btn.convertToWorldSpaceAR(cc.Vec2.ZERO),
          i = cc.find("Canvas").getChildByName("frame_diamond").getPosition(),
          n = this.node.parent.parent.parent.convertToNodeSpaceAR(o);
      e.setPosition(n), e.parent = this.node.parent.parent.parent, e.getComponent(u["default"]).init(p.Util.getRandomInt(0, 360), p.Util.getRandomInt(200, 400), i, this.frame_icon);
    }
  }, a([y(cc.Prefab)], e.prototype, "pfb_Item", void 0), a([y([cc.SpriteFrame])], e.prototype, "frame_Arr", void 0), a([y(cc.Label)], e.prototype, "label_title", void 0), a([y(cc.Node)], e.prototype, "node_Btn", void 0), a([y(cc.Node)], e.prototype, "node_togetIocn", void 0), a([y(cc.Node)], e.prototype, "node_rewardIocn", void 0), a([y(cc.Prefab)], e.prototype, "prefab", void 0), a([y(cc.SpriteFrame)], e.prototype, "frame_icon", void 0), a([y(cc.SpriteFrame)], e.prototype, "frame_get", void 0), a([y(cc.SpriteFrame)], e.prototype, "frame_recive", void 0), a([_], e);
}(cc.Component);

o["default"] = g;

cc._RF.pop();